﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using ORMapping;
using System.Data;
using PublicCommon;

namespace BLL
{
    public class CardHistoryBLL
    {
        public void AddCardHistory(Card cd)
        {
            CardHistory ch = new CardHistory();
            ch.CardID = cd;
            ch.CardNO = cd.CardNO;
            ch.UpdateDate = DateTime.Now;
            ch.UserID = HYSession.Session.GetValue(typeof(User).Name) as User;
            ch.CardType = cd.CardType;
            ch.CRegisterDate = cd.CRegisterDate;
            ch.EndDate = cd.EndDate;
            ch.MaxTimes = cd.MaxTimes;
            ch.MemberID = cd.MemberID;
            ch.Remark = cd.Remark;
            ch.StartDate = cd.StartDate;
            ch.UseTimes = cd.UseTimes;
            ch.Valid = cd.Valid;
            ch.ChangeBox = cd.ChangeBox;
            CardHistoryDAL chd = new CardHistoryDAL();
            chd.AddCardHistory(ch);
        }

        public IList<CardHistory> GetCardHistoryByCardId(Int32 CardID)
        {
            CardHistoryDAL chd = new CardHistoryDAL();
            return chd.GetCardHistoryByCardId(CardID);
        }

        public DataTable GetCardHistoryDataTable(Int32 CardID)
        {
            return NHibernateHelper.Convert.ConvertToDataTable<CardHistory>(GetCardHistoryByCardId(CardID));
        }
    }
}
